<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('mobile',20)->unique()->comment('手机号码');
            $table->string('username',20)->unique()->nullable()->comment('用户名');
            $table->string('nickname',20)->comment('昵称');
            $table->string('avatar',200)->nullable()->comment('头像地址');
            $table->string('password',128)->comment('登录密码');
            $table->string('paypassword',128)->nullable()->comment('支付密码');
            $table->string('wxopenid',100)->unique()->nullable()->comment('微信openid');
            $table->string('qqopenid',100)->unique()->nullable()->comment('qq openid');
            $table->string('wbopenid',100)->unique()->nullable()->comment('微博openid');
            $table->string('identitycard',20)->nullable()->comment('身份证');
            $table->string('realname',20)->comment('真实姓名');
            $table->dateTime('birthday')->nullable()->comment('用户生日');
            $table->string('sex',2)->default(0)->nullable()->comment('性别,1男2女0未知');
            $table->decimal('balance',16,2)->default(0)->comment('余额');
            $table->decimal('savemoney',16,2)->default(0)->comment('节省金额');
            $table->integer('point')->default(0)->comment('积分余额');
            $table->string('city',20)->nullable()->comment('常驻城市');
            $table->tinyInteger('issalesman')->default(0)->comment('是否地推人员');
            $table->tinyInteger('isdouble')->default(0)->comment('是否立翻账号');
            $table->tinyInteger('status')->default(1)->comment('账号状态');
            $table->integer('adminid')->comment('最后操作员ID');
            $table->integer('oldid')->comment('原系统ID');
            $table->string('salesmanid', 20)->comment('地推人员id');
            $table->tinyInteger('doublecoupons')->default(0)->comment('是否有翻倍券');
            $table->dateTime('firstrechargetime')->default(0)->comment('首次充值时间');
            $table->dateTime('firstordertime')->default(0)->comment('首次订单时间');
            $table->string('firstshopname')->comment('首次去消费的商家名称');
            $table->dateTime('logintime')->comment('最后登录时间');
            $table->string('registersource', 128)->default('')->comment('注册来源');
            $table->string('deviceid', 128)->default('')->comment('设备id号');
            $table->string('osversion', 32)->default('')->comment('设备id号');
            $table->string('phonetype', 128)->default('')->comment('设备id号');
            $table->string('versioncode', 32)->default('')->comment('设备id号');
            $table->string('ip', 32)->default('')->comment('注册ip');
            $table->string('registerarea', 128)->default('')->comment('注册地区');
            $table->integer('shopid', 11)->default(0)->comment('地推商家id');
            $table->string('iosorandroid', 32)->default('')->comment('越狱信息');
            $table->string('info', 512)->nullable()->comment('预留字段');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('users');
    }
}
